package com.yingjie.customcontrol;

import com.yingjie.addressbook.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageButton;
import android.widget.RelativeLayout;

public class TitleBar extends RelativeLayout {
	ImageButton btnBack;
	ImageButton btnRight;
    public TitleBar(Context context,AttributeSet attrs){  
        super(context,attrs);  
        LayoutInflater.from(context).inflate(R.layout.titlebar_layout, this, true);  
        btnBack = (ImageButton)findViewById(R.id.title_bar_btn_back);
        btnRight = (ImageButton)findViewById(R.id.title_btn_right);
    }
    public void setOnBackClickListener(OnClickListener btnOnBackClickListener){
    	btnBack.setOnClickListener(btnOnBackClickListener);
    }
    
    public void setOnRightClickListener(OnClickListener btnOnRightClickListener){
    	btnRight.setOnClickListener(btnOnRightClickListener);
    }
    
    public void setRightIcon(Integer resId){
    	btnRight.setImageResource(resId);
    }
    
    public void showBackButton(){
    	btnBack.setVisibility(VISIBLE);
    }
    
    public void showRightButton(){
    	btnRight.setVisibility(VISIBLE);
    }
}
